// ignore_for_file: file_names

import 'package:flutter/material.dart';

class MyApp12 extends StatelessWidget {
  const MyApp12(
      {super.key,
      this.title = '',
      this.content = '',
      this.textCol = Colors.black,
      this.textSize = 0});

  final String title;
  final String content;
  final Color textCol;
  final double textSize;
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          backgroundColor: Colors.orange,
          toolbarHeight: 100,
          title: Center(
            child: Text(
              '$title ',
              style: const TextStyle(color: Colors.white, fontSize: 50),
            ),
          ),
        ),
        body: const MyContainer(),
      ),
    );
  }
}

class MyContainer extends StatelessWidget {
  const MyContainer({super.key});

  @override
  Widget build(BuildContext context) {
    return ListView.separated(
      itemBuilder: (BuildContext context, int index) {
        return const GoodsItem();
      },
      separatorBuilder: (BuildContext context, int index) {
        return Container(
          height: 20,
          color: Colors.grey,
          child:
              const Text('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'),
        );
      },
      itemCount: 50,
    );
  }
}

class GoodsItem extends StatelessWidget {
  const GoodsItem({super.key});

  @override
  Widget build(BuildContext context) {
    Map data = {
      'createTime': "2024-08-15 21:49:48",
      'orderState': "待发货",
      'image':
          "https://yanxuan-item.nosdn.127.net/a09de222ed32efa8ffe359b1d5780574.jpg",
      'name': "茶水分离杯耐热隔热玻璃杯茶水分离杯耐热隔热玻璃杯茶水分离耐高温放心用",
      'totalNum': 2,
      'curPrice': 119.5,
      'attrsText': "规格: 白色240ml"
    };
    return Column(
      crossAxisAlignment: CrossAxisAlignment.end,
      children: [
        // 时间+待发货
        Container(
          padding: const EdgeInsets.all(10),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              // 时间
              Text(
                data['createTime'],
                style: const TextStyle(fontSize: 20),
              ),
              // 待发货
              Text(
                data['orderState'],
                style: const TextStyle(
                    fontSize: 20,
                    color: Colors.orange,
                    fontWeight: FontWeight.w900),
              )
            ],
          ),
        ),
        // 商品信息
        Container(
          padding: const EdgeInsets.all(20),
          child: Row(
            children: [
              // 商品图片
              Image.network(
                data['image'],
                width: 150,
              ),
              // 右侧信息
              Expanded(
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    // 名字+数量
                    Row(
                      children: [
                        Expanded(
                          // 商品名称
                          child: Text(
                            data['name'],
                            style: const TextStyle(fontSize: 20),
                          ),
                        ),
                        // 商品数量
                        Text(
                          '×${data['totalNum']}',
                          style: const TextStyle(fontSize: 20),
                        )
                      ],
                    ),
                    // 规格
                    Container(
                      padding: const EdgeInsets.all(10),
                      child: Text(
                        '${data['attrsText']}',
                        style: const TextStyle(color: Colors.grey),
                      ),
                    ),
                    // 价格
                    Container(
                      padding: const EdgeInsets.all(10),
                      child: Text(
                        '￥${data['curPrice']}',
                        style: const TextStyle(
                            fontSize: 20, fontWeight: FontWeight.w900),
                      ),
                    ),
                  ],
                ),
              )
            ],
          ),
        ),
        // 合计
        Container(
          padding: const EdgeInsets.all(10),
          child: Text('合计 ￥${data['curPrice'] * data['totalNum']}'),
        ),
        // 再次购买
        Container(
          padding: const EdgeInsets.all(10),
          child: Container(
            padding: const EdgeInsets.all(8),
            decoration: BoxDecoration(border: Border.all()),
            child: const Text('再次购买'),
          ),
        )
      ],
    );
  }
}
